package com.shse.dao;

import com.shse.meta.Article;
import com.shse.meta.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by shse on 3/12/2016.
 */

@Repository
public interface ArticleDao {

    @Select("select * from article")
    public List<Article> getAllArticle();

    @Select("select * from article where id=#{id}")
    public Article getArticleById(String id);

    @Select("select * from article left join users on article.userId=users.userId where users.userName=#{userName}")
    public List<Article> getArticlesByAuthor(@Param("userName") String author);

    @Update("update article set title=#{title},content=#{content} where id=#{id}")
    public void updateArticle(@Param("id") String id, @Param("title") String title, @Param("content") String content);

}
